package com.wisecoach.gatewayplus.info;

import com.wisecoach.gatewayplus.utils.GatewayUtils;
import org.hyperledger.fabric.client.identity.Signer;

import java.security.cert.X509Certificate;

/**
 * {@code @author:} wisecoach
 * {@code @date:} 2023/3/2 下午8:45
 * {@code @version:} 1.0.0
 */


public class GatewayInfoImpl implements GatewayInfo {

    private final String mspId;
    private final Signer signer;
    private final X509Certificate certificate;

    public GatewayInfoImpl(String mspId, Signer signer, X509Certificate certificate) {
        this.mspId = mspId;
        this.signer = signer;
        this.certificate = certificate;
    }

    public GatewayInfoImpl(String mspId, String secretPath, String certPath) {
        this.mspId = mspId;
        this.signer = GatewayUtils.getSignerByFile(secretPath);
        this.certificate = GatewayUtils.getCertByFile(certPath);
    }

    @Override
    public String getMspId() {
        return mspId;
    }

    @Override
    public Signer getSigner() {
        return signer;
    }

    @Override
    public X509Certificate getCertificate() {
        return certificate;
    }
}
